package com.qyhl.webtv.module_live.teletext.list;

import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.common.CommonUtils;
import com.qyhl.webtv.commonlib.entity.live.LiveRoomBean;
import com.qyhl.webtv.module_live.common.LiveUrl;

import java.util.List;

/**
 * Created by qyhl2 on 2017/12/12.
 *
 * @author helin
 */
public class LiveListModel implements LivesListContract.LiveListModel {


    private final LivesListContract.LiveListPresenter presenter;

    LiveListModel(LivesListContract.LiveListPresenter presenter) {
        this.presenter = presenter;
    }

    /**
     * 获取直播列表startForegroundService
     */
    @Override
    public void getLiveList(final String liveId, String liveType) {
        EasyHttp.get(LiveUrl.GET_LIVES_LIST)
                .params("tagName", CommonUtils.getInstance().getSiteName())
                .params("siteId", CommonUtils.getInstance().getSite() + "")
                .params("liveId", liveId)
                .params("liveType", liveType)
                .execute(new SimpleCallBack<List<LiveRoomBean>>() {
                    @Override
                    public void onError(ApiException e) {
                        presenter.error("获取数据失败",!liveId.equals("0"));
                    }

                    @Override
                    public void onSuccess(List<LiveRoomBean> liveRoomBeans) {
                        presenter.success(liveRoomBeans,!liveId.equals("0"));
                    }
                });


    }




}
